package org.jz.gae.redbook.spb.server.controller;

import org.jz.gae.redbook.spb.server.helper.DistrictHelper;
import org.jz.gae.redbook.spb.shared.DistrictEntityView;

import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.KeyFactory;

public class DistrictUtils
{
	public static void reflectEntityToView(
			Entity district,
			DistrictEntityView newDistrict)
	{
		newDistrict.setDistrictKey(KeyFactory.keyToString(district.getKey()));
		newDistrict.setDistrictRusName((String)district.getProperty(DistrictHelper.DISTRICT_RUS_NAME));
		newDistrict.setDistrictEngName((String)district.getProperty(DistrictHelper.DISTRICT_ENG_NAME));
		newDistrict.setDistrictNote((String)district.getProperty(DistrictHelper.DISTRICT_NOTE));
	}
	
    public static void reflectViewToEntity(
    		DistrictEntityView _District,
			Entity district)
	{
	    district.setProperty(DistrictHelper.DISTRICT_RUS_NAME, 	_District.getDistrictRusName());
		district.setProperty(DistrictHelper.DISTRICT_ENG_NAME, _District.getDistrictEngName());
		district.setProperty(DistrictHelper.DISTRICT_NOTE, _District.getDistrictNote());
	}

}
